import java.util.*;

public class SolutionInterview16_22 {
    public List<String> printKMoves(int K) {
        int[] dx=new int[]{1,0,-1,0};
        int[] dy=new int[]{0,-1,0,1};
        char[] c=new char[]{'R','D','L','U'};
        int l=0,r=0,u=0,d=0;
        Map<List<Integer>,Boolean> map=new HashMap<>();
        int x=0,y=0,t=0;
        map.put(Arrays.asList(0,0),false);
        for (int i = 0; i < K; i++) {
            List<Integer> list=Arrays.asList(x,y);
            boolean flag=map.get(list);
            map.put(list,!flag);
            if (flag){
                t=(t+3)%4;
            }else {
                t=(t+1)%4;
            }
            x+=dx[t];
            y+=dy[t];
            l=Math.min(l,x);
            r=Math.max(r,x);
            u=Math.max(y,u);
            d=Math.min(y,d);
            List<Integer> list1=Arrays.asList(x,y);
            map.putIfAbsent(list1,false);
        }
        List<String> ans=new ArrayList<>();
        for (int i=u;i>=d;i--){
            StringBuilder stringBuilder=new StringBuilder();
            for (int j=l;j<=r;j++){
                if (i==y && j==x){
                    stringBuilder.append(c[t]);
                }else {
                    if (!map.containsKey(Arrays.asList(j,i))){
                        stringBuilder.append('_');
                    }else {
                        stringBuilder.append(map.get(Arrays.asList(j,i))?'X':'_');
                    }
                }
            }
            ans.add(stringBuilder.toString());
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new SolutionInterview16_22().printKMoves(5));
    }
}
